[XEND] Accomodate extra "devices" in SXP that do not have DevControllers
authorAlastair Tse <atse@xensource.com>
Fri, 17 Nov 2006 17:57:49 +0000 (17:57 +0000)
committerAlastair Tse <atse@xensource.com>
Fri, 17 Nov 2006 17:57:49 +0000 (17:57 +0000)
Signed-off-by: Alastair Tse <atse@xensource.com>
tools/python/xen/xend/XendConfig.py
tools/python/xen/xend/XendDevices.py
tools/python/xen/xend/XendDomainInfo.py

index 1b0c58d3167f142a5f23cbeb6e5ccc06be6317f3..ad5e0ad4a3e699d729b99e88959b2a405b019b2f 100644 (file)
@@ -780,7 +780,8 @@ class XendConfig(dict):
 
         # Verify devices
         for d_uuid, (d_type, d_info) in self['device'].items():
-            if d_type not in XendDevices.valid_devices():
+            if d_type not in XendDevices.valid_devices() and \
+               d_type not in XendDevices.pseudo_devices():
                 raise XendConfigError('Invalid device (%s)' % d_type)
 
         # Verify restart modes
@@ -798,7 +799,8 @@ class XendConfig(dict):
             self['vtpm_refs'] = []
 
     def device_add(self, dev_type, cfg_sxp = None, cfg_xenapi = None):
-        if dev_type not in XendDevices.valid_devices():
+        if dev_type not in XendDevices.valid_devices() and \
+           dev_type not in XendDevices.pseudo_devices():
             raise XendConfigError("XendConfig: %s not a valid device type" %
                             dev_type)
 
@@ -917,8 +919,8 @@ class XendConfig(dict):
             if dev_type == 'pci': # special case for pci devices
                 pci_devs.append(dev_info)
             else:
-                sxpr =  self.device_sxpr(dev_type = dev_type,
-                                         dev_info = dev_info)
+                sxpr = self.device_sxpr(dev_type = dev_type,
+                                        dev_info = dev_info)
                 sxprs.append((dev_type, sxpr))
 
         # if we have any pci_devs, we parse them differently into
index 4125cee2aed8554aca50385e5d4a82fd0f568465..2286824087c83d3d14b107731707b23d7f784320 100644 (file)
@@ -48,6 +48,11 @@ class XendDevices:
         return cls.controllers.keys()
     valid_devices = classmethod(valid_devices)
 
+    #@classmethod
+    def pseudo_devices(cls):
+        return ['console']
+    pseudo_devices = classmethod(pseudo_devices)
+
     #@classmethod
     def make_controller(cls, name, domain):
         """Factory function to make device controllers per domain.
index 7e91ac9bd0fbad0c97d168309f50480a5b47ad30..295925d1da57131cf8a488a9b509115def43dad9 100644 (file)
@@ -1119,8 +1119,9 @@ class XendDomainInfo:
         @raise: VmError for invalid devices
         """
         for (devclass, config) in self.info.all_devices_sxpr():
-            log.info("createDevice: %s : %s" % (devclass, config))
-            self._createDevice(devclass, config)
+            if devclass in XendDevices.valid_devices():
+                log.info("createDevice: %s : %s" % (devclass, config))
+                self._createDevice(devclass, config)
 
         if self.image:
             self.image.createDeviceModel()